﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Stacked Sparkline</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    
    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
        /*code_begin*/
        var spreadNS = GcSpread.Sheets;
        $(document).ready(function () {
            var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 2 });
            initSpread(spread);
        });

        function initSpread(spread) {
            spread.newTabVisible(false);
            this.initHorizontalSparkline(spread.sheets[0], "Horizontal");
            this.initVerticalSparkline(spread.sheets[1], "Vertical");
        };

        function initHorizontalSparkline(sheet, name) {
            sheet.isPaintSuspended(true);
            sheet.setName(name);

            sheet.addSpan(0, 0, 1, 5);
            sheet.getCell(0, 0).value("Sales by State").font("20px Arial").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);

            sheet.getCells(1, 0, 1, 4).foreColor("white").backColor("Accent 4").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);
            sheet.setValue(1, 0, "State");
            sheet.setValue(1, 1, "Product 1");
            sheet.setValue(1, 2, "Product 2");
            sheet.setValue(1, 3, "Product 3");
            sheet.setValue(1, 4, "Diagram");
            sheet.setValue(2, 0, "Idaho");
            sheet.setValue(2, 1, 10000);
            sheet.setValue(2, 2, 12000);
            sheet.setValue(2, 3, 15000);
            sheet.setValue(3, 0, "Montana");
            sheet.setValue(3, 1, 11000);
            sheet.setValue(3, 2, 10000);
            sheet.setValue(3, 3, 15000);
            sheet.setValue(4, 0, "Oregon");
            sheet.setValue(4, 1, 10000);
            sheet.setValue(4, 2, 17000);
            sheet.setValue(4, 3, 12000);
            sheet.setValue(5, 0, "Washington");
            sheet.setValue(5, 1, 15000);
            sheet.setValue(5, 2, 10000);
            sheet.setValue(5, 3, 15000);
            sheet.setValue(6, 0, "Utah");
            sheet.setValue(6, 1, 10000);
            sheet.setValue(6, 2, 15000);
            sheet.setValue(6, 3, 12000);
            sheet.setValue(7, 1, "orange");
            sheet.setValue(7, 2, "purple");
            sheet.setValue(7, 3, "yellowgreen");
            sheet.setFormatter(-1, 1, "$#,##0");
            sheet.setFormatter(-1, 2, "$#,##0");
            sheet.setFormatter(-1, 3, "$#,##0");

            sheet.setFormula(2, 4, '=STACKEDSPARKLINE(B3:D3,B8:D8,B2:D2,40000)');
            sheet.setFormula(3, 4, '=STACKEDSPARKLINE(B4:D4,B8:D8,B2:D2,40000)');
            sheet.setFormula(4, 4, '=STACKEDSPARKLINE(B5:D5,B8:D8,B2:D2,40000)');
            sheet.setFormula(5, 4, '=STACKEDSPARKLINE(B6:D6,B8:D8,B2:D2,40000)');
            sheet.setFormula(6, 4, '=STACKEDSPARKLINE(B7:D7,B8:D8,B2:D2,40000)');

            sheet.setRowHeight(0, 50);
            sheet.setRowHeight(1, 25);
            for (var i = 2; i < 7; i++) {
                sheet.setRowHeight(i, 45);
            }
            sheet.setRowHeight(7, 0);
            sheet.setColumnWidth(0, 100);
            sheet.setColumnWidth(1, 120);
            sheet.setColumnWidth(2, 120);
            sheet.setColumnWidth(3, 120);
            sheet.setColumnWidth(4, 200);

            sheet.isPaintSuspended(false);
        }

        function initVerticalSparkline(sheet, name) {
            sheet.isPaintSuspended(true);
            sheet.setName(name);

            sheet.setRowHeight(0, 50);
            sheet.addSpan(0, 0, 1, 5);
            sheet.getCell(0, 0).value("Sales by State").font("20px Arial").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);

            sheet.setColumnWidth(0, 120);
            sheet.setColumnWidth(1, 120);
            sheet.setColumnWidth(2, 120);
            sheet.setColumnWidth(3, 120);
            sheet.setColumnWidth(4, 120);

            sheet.setRowHeight(2, 200);

            sheet.setFormula(1, 0, "=Horizontal!A3");
            sheet.setFormula(2, 0, '=STACKEDSPARKLINE(Horizontal!B3:D3,Horizontal!B8:D8,Horizontal!B2:D2,40000,,,,,,,TRUE)');
            sheet.setFormula(1, 1, "=Horizontal!A4");
            sheet.setFormula(2, 1, '=STACKEDSPARKLINE(Horizontal!B4:D4,Horizontal!B8:D8,Horizontal!B2:D2,40000,,,,,,,TRUE)');
            sheet.setFormula(1, 2, "=Horizontal!A5");
            sheet.setFormula(2, 2, '=STACKEDSPARKLINE(Horizontal!B5:D5,Horizontal!B8:D8,Horizontal!B2:D2,40000,,,,,,,TRUE)');
            sheet.setFormula(1, 3, "=Horizontal!A6");
            sheet.setFormula(2, 3, '=STACKEDSPARKLINE(Horizontal!B6:D6,Horizontal!B8:D8,Horizontal!B2:D2,40000,,,,,,,TRUE)');
            sheet.setFormula(1, 4, "=Horizontal!A7");
            sheet.setFormula(2, 4, '=STACKEDSPARKLINE(Horizontal!B7:D7,Horizontal!B8:D8,Horizontal!B2:D2,40000,,,,,,,TRUE)');


            sheet.getCells(1, 0, 1, 4).foreColor("white").backColor("Accent 4").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);

            sheet.isPaintSuspended(false);
        }
        /*code_end*/
    </script>

</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width: 100%; height: 420px; border: 1px solid gray;"></div>
    </div>
</body>
</html>